package extreme.fizzbuzz;

public class FizzBuzz2 {

    public static void main(String[] args) {

        int[] students = new int[] {1,4,6,10,14,60,21,140,210,13,3,130,133,30,63,1330,630,52,51,5,56,15,252,245,105,17,27,170,7,270,147,70,1470,53,153,235,532,135,1533,35,315,37,73,237,370,371,2370,378,3710,2370,157,57,275,574,75,567,175,1575,1357,537,1375,3157,375,357,3745,735};

        for(int student : students) {
         //   System.out.println("student " + student + " says " + getSerialNum(student));

            System.out.println(getSerialNum(student));

        }
    }

    public static String getSerialNum(int student) {

        StringBuffer serialNum = new StringBuffer(student);


        if (String.valueOf(student).contains(FbwEnum.SEVEN.getValue()+"")) {
            //.??
            if (!String.valueOf(student).contains(FbwEnum.FIVE.getValue()+"")) {
                if (String.valueOf(student).contains(FbwEnum.THREE.getValue()+"")) {
                    return FbwEnum.THREE.getName();
                }
            }
            serialNum.append(dNum(student, FbwEnum.THREE));
            serialNum.append(dNum(student, FbwEnum.SEVEN));
        }else if (String.valueOf(student).contains(FbwEnum.FIVE.getValue()+"")) {

            serialNum.append(dNum(student, FbwEnum.FIVE));
            serialNum.append(dNum(student, FbwEnum.SEVEN));
        }else if (String.valueOf(student).contains(FbwEnum.THREE.getValue()+"")) {
            return FbwEnum.THREE.getName();
        }else{
            serialNum.append(dNum(student, FbwEnum.THREE));
            serialNum.append(dNum(student, FbwEnum.FIVE));
            serialNum.append(dNum(student, FbwEnum.SEVEN));
        }







        return serialNum.toString().equals("") ? String.valueOf(student) : serialNum.toString();
    }

    private static String catain(int student, FbwEnum fbwEnum) {
        return "";
    }

    private static String dNum(int student, FbwEnum fbwEnum){
        if (student%fbwEnum.getValue() == 0) {
            return FbwEnum.valueToName(fbwEnum.getValue());
        }
        return "";
    }
}